//==============================================================================
// militaryUpgradeElves
//==============================================================================
rule militaryUpgradeElves
   minInterval 31
   active
   runImmediately
{
	if(cMyCulture != cCultureGreek)
	{
      		xsDisableSelf();
		return;
	}
		
   	//Must be setup for resources before we do any of this.
	if ( (kbSetupForResource(kbBaseGetMainID(cMyID), cResourceWood, 25.0, 400) == false) ||
	     (kbSetupForResource(kbBaseGetMainID(cMyID), cResourceFood, 25.0, 400) == false) )
		return;

	//Define Armory Progression (all civs)

	int apid = aiPlanCreate("armoryUpgradeElves",cPlanProgression);
   	if (apid >= 0)
   	{ 
      		aiPlanSetVariableBool(apid, cProgressionPlanRunInParallel, 0, true);
      		aiPlanSetDesiredPriority(apid, 75);
		aiPlanSetEscrowID(apid, cMilitaryEscrowID);
      		aiPlanSetBaseID(apid, kbBaseGetMainID(cMyID));
      
		aiPlanSetNumberVariableValues(apid, cProgressionPlanGoalTechID, 11, true);

		if (aiGetWorldDifficulty() == cDifficultyNightmare)
			aiPlanSetNumberVariableValues(apid, cProgressionPlanGoalTechID, 17, true);

		aiPlanSetVariableInt(apid, cProgressionPlanGoalTechID, 0, cTechLeatherArmor);
		aiPlanSetVariableInt(apid, cProgressionPlanGoalTechID, 1, cTechWoodenShields);
		aiPlanSetVariableInt(apid, cProgressionPlanGoalTechID, 2, cTechBow);
		aiPlanSetVariableInt(apid, cProgressionPlanGoalTechID, 3, cTechSword);
		aiPlanSetVariableInt(apid, cProgressionPlanGoalTechID, 4, cTechSaddle);
		aiPlanSetVariableInt(apid, cProgressionPlanGoalTechID, 5, cTechStirrups);
		aiPlanSetVariableInt(apid, cProgressionPlanGoalTechID, 6, cTechQuiver);
		aiPlanSetVariableInt(apid, cProgressionPlanGoalTechID, 7, cTechChainMail);
		aiPlanSetVariableInt(apid, cProgressionPlanGoalTechID, 8, cTechShields);
		aiPlanSetVariableInt(apid, cProgressionPlanGoalTechID, 9, cTechPlateMail);
		aiPlanSetVariableInt(apid, cProgressionPlanGoalTechID, 10, cTechHelmets);
      
		if (aiGetWorldDifficulty() == cDifficultyNightmare)
		{
			aiPlanSetVariableInt(apid, cProgressionPlanGoalTechID, 11, cTechVisors);
			aiPlanSetVariableInt(apid, cProgressionPlanGoalTechID, 12, cTechLongSword);
			aiPlanSetVariableInt(apid, cProgressionPlanGoalTechID, 13, cTechArmGuard);
			aiPlanSetVariableInt(apid, cProgressionPlanGoalTechID, 14, cTechThumbRing);
			aiPlanSetVariableInt(apid, cProgressionPlanGoalTechID, 15, cTechFletching);
			aiPlanSetVariableInt(apid, cProgressionPlanGoalTechID, 16, cTechTwoHandedSword);
		}

		aiPlanSetActive(apid);
	}
	else
		aiPlanDestroy(apid);

	//Define Foundry Progression (all civs)

	int fpid = aiPlanCreate("foundryUpgradeElves",cPlanProgression);
   	if (fpid >= 0)
   	{ 
      		aiPlanSetVariableBool(fpid, cProgressionPlanRunInParallel, 0, true);
      		aiPlanSetDesiredPriority(fpid, 75);
		aiPlanSetEscrowID(fpid, cMilitaryEscrowID);
      		aiPlanSetBaseID(fpid, kbBaseGetMainID(cMyID));
      
		aiPlanSetNumberVariableValues(fpid, cProgressionPlanGoalTechID, 5, true);

		if (aiGetWorldDifficulty() == cDifficultyNightmare)
			aiPlanSetNumberVariableValues(fpid, cProgressionPlanGoalTechID, 10, true);

		aiPlanSetVariableInt(fpid, cProgressionPlanGoalTechID, 0, cTechCopper);
		aiPlanSetVariableInt(fpid, cProgressionPlanGoalTechID, 1, cTechBronzeAlloy);
		aiPlanSetVariableInt(fpid, cProgressionPlanGoalTechID, 2, cTechMetalCasting);
		aiPlanSetVariableInt(fpid, cProgressionPlanGoalTechID, 3, cTechMetalHardening);
		aiPlanSetVariableInt(fpid, cProgressionPlanGoalTechID, 4, cTechAnnaAngron);
      
		if (aiGetWorldDifficulty() == cDifficultyNightmare)
		{
			aiPlanSetVariableInt(fpid, cProgressionPlanGoalTechID, 5, cTechAnnealing);
			aiPlanSetVariableInt(fpid, cProgressionPlanGoalTechID, 6, cTechMeteoricIron);
			aiPlanSetVariableInt(fpid, cProgressionPlanGoalTechID, 7, cTechTheLoreofTelchar);
			aiPlanSetVariableInt(fpid, cProgressionPlanGoalTechID, 8, cTechAnnaEol);
			aiPlanSetVariableInt(fpid, cProgressionPlanGoalTechID, 9, cTechMithril);
		}

		aiPlanSetActive(fpid);
	}
	else
		aiPlanDestroy(fpid);

   	//Define Military Progression Plan
   	int pid=aiPlanCreate("militaryUpgradeMen", cPlanProgression);
   	if (pid >= 0)
   	{ 
      		aiPlanSetVariableBool(pid, cProgressionPlanRunInParallel, 0, true);
      		aiPlanSetDesiredPriority(pid, 75);
		aiPlanSetEscrowID(pid, cMilitaryEscrowID);
      		aiPlanSetBaseID(pid, kbBaseGetMainID(cMyID));
      
		aiPlanSetNumberVariableValues(pid, cProgressionPlanGoalTechID, 6, true);

		if (aiGetWorldDifficulty() == cDifficultyNightmare)
			aiPlanSetNumberVariableValues(pid, cProgressionPlanGoalTechID, 10, true);
        			
     		aiPlanSetVariableInt(pid, cProgressionPlanGoalTechID, 0, cTechAredhel);
         		aiPlanSetVariableInt(pid, cProgressionPlanGoalTechID, 1, cTechConscription);
         		aiPlanSetVariableInt(pid, cProgressionPlanGoalTechID, 2, cTechArchersofMirkwood);
         		aiPlanSetVariableInt(pid, cProgressionPlanGoalTechID, 3, cTechBelthil);
         		aiPlanSetVariableInt(pid, cProgressionPlanGoalTechID, 4, cTechDrilling);
         		aiPlanSetVariableInt(pid, cProgressionPlanGoalTechID, 5, cTechArchersofRivendell);

		if (aiGetWorldDifficulty() == cDifficultyNightmare)
		{
        			aiPlanSetVariableInt(pid, cProgressionPlanGoalTechID, 6, cTechThe Lore of Tauron);
         			aiPlanSetVariableInt(pid, cProgressionPlanGoalTechID, 7, cTechTactics);
         			aiPlanSetVariableInt(pid, cProgressionPlanGoalTechID, 8, cTechArchersofLorien);
         			aiPlanSetVariableInt(pid, cProgressionPlanGoalTechID, 9, cTechWarfare);
		}

		aiPlanSetActive(pid);
	}
	else
		aiPlanDestroy(pid);


      	xsDisableSelf();
}

